<?php
if(!defined('BZ_XTBLOG')){
    exit('Access Denied!');
}
function exists($funName = '') {
    if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName,$tmp))
        return '';
    if(function_exists($funName)){
    	  return $funName;
    }
}
function Bingz_judge($content,$name,$post=''){
	  if($post == '1'){
	  	  $ssid=explode(''.$name.'',$content);
	  	  if($ssid[1]){
	  		   return '1';
	  	  }
	  } else {
	  		if(preg_match('/'.$name.'/',$content)){
	  	     return '1';
	      }
	  }
}
function Bingz_email_smtp_post($sendto_email,$subject,$body,$From='',$FromName=''){
	  global $db;
	  if(!$From){$From=Bingz_config('email_smtp_fromyh');}
	  if(!$FromName){$FromName=Bingz_config('email_smtp_fromname');}
 if(Bingz_config('email_smtp_sezhi') == '1'){
	  require (MBLOG_ROOT.'other/email/class.phpmailer.php');
	  $mail = new PHPMailer();
		$mail->IsSMTP();
		$mail->Host = Bingz_config('email_smtp_servers');
		$mail->SMTPDebug= 0;
		$mail->SMTPAuth = true;
		$mail->Username = Bingz_config('email_smtp_username');
		$mail->Password = authcode(Bingz_config('email_smtp_password'),'DECODE','Bingz');
		$mail->Port =Bingz_config('email_smtp_port');
		$mail->From =Bingz_config('email_smtp_from');
		$mail->FromName =$FromName;
	$mail->CharSet = "UTF-8";
	$mail->Encoding = "base64";
	$mail->AddReplyTo(Bingz_config('email_smtp_from'),$FromName);
	$mail->AddAddress($sendto_email,$From);
	$mail->IsHTML(true);
	$mail->Subject = $subject;
	$mail->Body =$body;
	$mail->AltBody ="text/html";
	if($mail->Send()){
		return '1';
	}else{
		return $mail->ErrorInfo;
	}
 }
}
function Bingz_sms_post($mobile,$content,$From='1'){
	global $db,$time;
	$usera=$db->get_one('user'," `mobile` = '$mobile'",'`mobile_d`');
	if($usera && $usera[mobile_d] == '0'){$mobile_d='1';}
 if(Bingz_config('sms_post_sezhi') == '1' && !$mobile_d){
	$sms_post_username=Bingz_config('sms_post_username');
  $sms_post_password=authcode(Bingz_config('sms_post_password'),'DECODE','Bingz');
  $sms_post_key=Bingz_config('sms_post_key');
	$smsfsb='http://sms.wapv.net/index.php?m=plugin&insert=Bingz_smscat&mod=sms_send&name='.$sms_post_username.'&pass='.$sms_post_password.'&key='.$sms_post_key.'&content='.urlencode($content).'&mobile='.$mobile.'&time='.$time.'';
  $contentzt=@file_get_contents(''.$smsfsb.'');
  if($contentzt == '1'){
		return '1';
	}else{
		return '0';
	}
 }
}
function Verification() {
	  global $db,$Bingz_fication;
		if($Bingz_fication == '2'){
			$an1 = 'abcdefghijkmnopqrstuvwxyz';
		} else if($Bingz_fication == '3'){
		  $an1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
		} else {
		  $an1 = '01234567890123456789';
		}
		for ($i = 0; $i < 4 ; $i++) {
			$start = rand(1,strlen($an1) - 1);
			$randnum .= substr($an1,$start,1);
		}
		setcookie('Bingz_yzm',$randnum);
		return $randnum;
}
function Bingz_yzm($table){//验证码服务
	global $_POST,$_COOKIE;
	if(!$table){$table='0';}
	$Binz_yzm=$_COOKIE['Bingz_yzm'];
  if(!$table or $Binz_yzm != $table){
	   $sql='1';
  }
  return $sql;
}
function addslashesaql($StrFiltrate,$type='0'){
	  	global $db,$_config,$bzsid;
	 if($type == '1'){
	 	  $StrFiltrate=urldecode($StrFiltrate);
	    $StrFiltrate = preg_replace('/&((#(\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1',$StrFiltrate);
   }
   $ArrFiltrate=explode(',','#,select,insert,and,update,delete,\',\/\*,\*,\.\.\/,\.\/,union,into,load_file,SELECT,INSERT,AND,OR,UPDATE,DELETE,UNION,INTO,LOAD_FILE,OUTFILE');
   foreach ($ArrFiltrate as $key){
       if (@eregi($key,$StrFiltrate)){
          $StrFiltrate=str_replace($key,'',$StrFiltrate);
       }
   }
   return $StrFiltrate;
}
function daddsla_add($string,$force='0'){
   if(!get_magic_quotes_gpc()) {
       if(is_array($string)) {
          foreach($string as $key => $val) { 
                  $string[$key] = daddsla_add($val,$force); 
          }
       } else {
          $string = addslashes($string); 
       } 
   }
   $string=addslashesaql($string,$force);
   return $string; 
}
function verify_id($id=null) { 
if (!is_numeric($id)) { $id='';  }
$id = intval($id);
return $id; 
}
function str_check($str) { 
if (!get_magic_quotes_gpc()) {
$str = addslashes($str);
} 
$str = str_replace("_", "\_", $str);
$str = str_replace("%", "\%", $str);
return $str; 
}
function post_check($post) { 
if (!get_magic_quotes_gpc()) {
$post = addslashes($post);
} 
$post = str_replace("_", "\_", $post);
$post = str_replace("%", "\%", $post);
$post = nl2br($post);
$post = htmlspecialchars($post);
return $post; 
} 
function ob_gzip($content){
	global $Bingz_gzip;
	if($Bingz_gzip > '0' && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && !headers_sent() && extension_loaded('zlib') && strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip')!==false ){
		 $content = gzencode($content,$Bingz_gzip);
		 header('Content-Encoding: gzip');
		 header('Vary: Accept-Encoding');
		 header('Content-Length: '.strlen($content));
	}
	return $content;
}
function getServe(){
  $ServerName = strtolower($_SERVER['SERVER_NAME']?$_SERVER['SERVER_NAME']:$_SERVER['HTTP_HOST']);
  if(strpos($ServerName,'http://')){  
     return str_replace('http://','',$ServerName);
  } 
  $ServerN=explode("/",$ServerName);
  return $ServerN[0];
}
function Browser(){
  $hqkhbua =strtolower($_SERVER['HTTP_USER_AGENT']);
  $andwebd ='/(Windows)/i';
  $android ='/(android|iphone|ipad)/i';
  $waproid ='/(Profile|Configuration|160×160|176×220|240×240|240×320|320×240|nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile|wap)/i'; 
    if(preg_match($andwebd,$hqkhbua)) {
       $web='web';
    }elseif(preg_match($android,$hqkhbua)) {
       $web='wpc';
    }elseif(preg_match($waproid,$hqkhbua) ) {
       $web='wap';
    }else{
       $web=Bingz_config('Site_config_banb');
       if(!in_array($web,array('wap', 'wpc','web'))) {
       $web='wpc';
       }
    }
  return $web;
}
function ip_address($ip){
    $url="http://ip.taobao.com/service/getIpInfo.php?ip=".$ip;
    @$ip=json_decode(file_get_contents($url)); 
    $data = (array)$ip->data;
    if($data[region_id] != $data[city_id] ){
    	 $city=$data[city];
    }
  return $data[country].$data[region].$city.$data[isp]; 
}
function Bingz_create_folder($table){
     if(!file_exists(''.$table.'/')){
			  @mkdir("$table/",0777,true);
           $fp=fopen("$table/index.php","w");
           $write=fputs($fp,"");
           fclose($fp);
	   }
}
#############################
function user_mm($mm){
	$mma=md5(md5($mm));
  $mmb=substr($mma,-18,18);
	$mmc=md5(md5($mmb));
  $mmd=substr($mmc,-10,10);
	return $mmd;
}
function Bingz_sjm($len,$lx=''){
	if($lx == '1'){
		$srcstr="012345678901234567890123456789";
	}else if($lx == '2'){
		$srcstr="qwertyuioplkjhgfdsazxcvbnmcvbnm";
	}else{
    $srcstr="0123456789qwertyuioplkjhgfdsazxcvbnm";
  }
  mt_srand();
  $strs="";
	for($i=0;$i< $len;$i++){
	    $strs.=$srcstr[mt_rand(0,30)];
	}
  return $strs;
}
############################################
function Bingz_time($xstime){
     $xssj=date('H:i',$xstime);
     $sjms=$time - $xstime;
     $taa =$time-strtotime(date("Y-m-d 00:00:00"));
	if($sjms < $taa){
		 $sjts='今天 '.$xssj;
	}else if($sjms < ((3600*24)+$taa)){
		 $sjts='昨天 '.$xssj;
	}else if($sjms < ((3600*24*2)+$taa)){
		 $sjts='前天 '.$xssj;
	}else{
     $sjts=date('Y-m-d H:i',$xstime);
	}
	return $sjts;
}
function Bingz_time_q($xstime){
	  global $time;
  $sjts=date('Y-m-d',$xstime);
	return $sjts;
}
function Bingz_time_m($ts1){
	  $ts1 = $ts1;
  	$ts2 = strtotime(date("Y-m-d H:i:s"));
	$time_at3=abs($ts1-$ts2);
	if($time_at3==0){
		$dt_time="刚刚";
	}elseif($time_at3 < 60){
		$dt_time=$time_at3."秒前";
	}elseif($time_at3 < 3600){
		$dt_time1=ceil($time_at3/60)-1;
		$dt_time=$dt_time1."分钟前";
		if($dt_time1==60)
			$dt_time="1小时前";
	}elseif($time_at3 < (3600*24)){
		$dt_time1=ceil($time_at3/3600)-1;
		$dt_time=$dt_time1."小时前";
		if($dt_time1==24)
			$dt_time="1天前";
	}else{
		$dt_time1=ceil($time_at3 / (3600*24))-1;
		$dt_time=$dt_time1."天前";
		if($dt_time1==365)
			$dt_time="1年前";
	}
	 return $dt_time;
}
function Bingz_time_d($ts1){
	global $time;
	if($ts1 == '0'){
		$dt_time='无限制时间';
	}else{
	  $time    =$ts1-$time;
	  $time_at3=intval($time/(3600*24));
	  $time_at2=$time_at3*(3600*24);
	  $time_at4=intval(($time-$time_at2)/(3600));
	  if($time_at3){
		  $dt_time=$time_at3.'天';
	  }
	  if($time_at4){
		  $dt_timexd=$time_at4.'小时';
	  }
  }
	 return $dt_time.$dt_timexd;
}
function Bingz_time_f($xstime){
  $sjts=date('Y/m/d H:i',$xstime);
	return $sjts;
}

function Bingz_upload_images($content){//获取图片
       $ArrFiltrate=explode('.',$content);
       $pinfoiltrat=$ArrFiltrate[0].'_data.'.$ArrFiltrate[1];
       if(file_exists($pinfoiltrat)){
           	  $content=$pinfoiltrat;
       }else{
           	  $content=$content;
       }
   return $content;
}
function Bingz_upload($destination_folder,$scfs='3',$qzsysz='1',$fjname=''){
	/*
	1.上传目录
	2.上传类型       1图片。    2附件.     3全部
  3.强制水印设置   1默认关闭. 2系统开启
	4.附文件名称
	*/
	global $db,$time,$Bingz_images_width,$Bingz_images_width;
	  $destination_folder='data/'.$destination_folder;
  	if($scfs == '1'){
  		       $uptypes=Bingz_config('upload_config_tplx');
  		$max_file_size =Bingz_config('upload_config_tplxdx');
  	}elseif($scfs == '2'){
  		       $uptypes=Bingz_config('upload_config_fjlx');
  		$max_file_size =Bingz_config('upload_config_fjlxdx');
  	}else{
  		       $uptypes=''.Bingz_config('upload_config_fjlx').','.Bingz_config('upload_config_tplx').','.$scfs;
  		$max_file_size =Bingz_config('upload_config_fjlxdx');
  	}
    $watermark    =Bingz_config('upload_config_sysz');
    $waterstring  =Bingz_config('upload_config_syname');
    $waterposition=Bingz_config('upload_config_sydz');
  	if($qzsysz == '1'){ $watermark ='';}
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
    $file = $_FILES['upfile'];
    $wjdx =$file['size']/1024;
    $ssnm =explode(".",$file['name']);
    $fjcks=$ssnm[count($ssnm)-1];
    if(!$file['name']){
        $mmm=array('1'=>'0','2'=>'没有上传文件！注意服务器限制最大上传'.ini_get("upload_max_filesize").'！('.$file['error'].')','3'=>'','4'=>'','5'=>'');
    }else if(!file_exists($file['tmp_name'])){
        $mmm=array('1'=>'0','2'=>'获取上传文件失败！注意服务器限制最大上传'.ini_get("upload_max_filesize").'！('.$file['error'].')' ,'3'=>'','4'=>'','5'=>'');
    }else if(!is_uploaded_file($file['tmp_name'])){
        $mmm=array('1'=>'0','2'=>'非法上传！','3'=>'','4'=>'','5'=>'');
    }else if($max_file_size < $wjdx){
        $mmm=array('1'=>'0','2'=>'文件太大！系统规定上传'.$max_file_size.'kb','3'=>'','4'=>'','5'=>'');
    }else if($uptypes == "" || !in_array($fjcks, explode(",", $uptypes))){
        $mmm=array('1'=>'0','2'=>'文件类型不符','3'=>'','4'=>'','5'=>'');
    }else{
        if(!file_exists($destination_folder)){
           @mkdir($destination_folder,0777,true);
        }
        $filename=$file['tmp_name'];
        $pinfo=pathinfo($file['name']);
        $ftype=$pinfo['extension'];
        $destination = $destination_folder.$fjname.$time.".".$ftype;
        if (file_exists($destination)){
           $mmm=array('1'=>'0','2'=>"文件名存在! ",'3'=>'','4'=>'','5'=>'');
        }else if(!move_uploaded_file($filename, $destination)){
           $mmm=array('1'=>'0','2'=>"保存文件失败!",'3'=>'','4'=>'','5'=>'');
        }else{
           $pinfo=pathinfo($destination);
           $fname=$pinfo[basename];

           if(in_array($fjcks, explode(",", Bingz_config('upload_config_tplx')))){//判断图片
               $image_size = getimagesize($destination);
               if($watermark == '1'){
               ###################
                     $thumb=imagecreatetruecolor($image_size[0],$image_size[1]);
                     switch ($image_size[2]){
                       case 1:
                       $source =imagecreatefromgif($destination);
                       break;
                       case 2:
                       $source =imagecreatefromjpeg($destination);
                       break;
                       case 3:
                       $source =imagecreatefrompng($destination);
                       break;
                       case 6:
                       $source =imagecreatefromwbmp($destination);
                       break;
                     default:
                     }
                     imagecopy($thumb,$source,0,0,0,0,$image_size[0],$image_size[1]);
                          
                          $iinfoaa=getimagesize($waterstring);
                          switch ($iinfoaa[2]){
                             case 1:
                             $simage1 =imagecreatefromgif($waterstring);
                             break;
                             case 2:
                             $simage1 =imagecreatefromjpeg($waterstring);
                             break;
                             case 3:
                             $simage1 =imagecreatefrompng($waterstring);
                             break;
                             case 6:
                             $simage1 =imagecreatefromwbmp($waterstring);
                             break;
                          }
                          if($waterposition == '1'){
                             imagecopy($thumb,$simage1,2,2,0,0,$iinfoaa[0],$iinfoaa[1]);
                          }else if($waterposition == '2'){
                             imagecopy($thumb,$simage1,$image_size[0]-$iinfoaa[0]-2,2,0,0,$iinfoaa[0],$iinfoaa[1]);
                          }else if($waterposition == '3'){
                             imagecopy($thumb,$simage1,2,$image_size[1]-$iinfoaa[1]-2,0,0,$iinfoaa[0],$iinfoaa[1]);
                          }else if($waterposition == '4'){
                             imagecopy($thumb,$simage1,$image_size[0]-$iinfoaa[0]-2,$image_size[1]-$iinfoaa[1]-2,0,0,$iinfoaa[0],$iinfoaa[1]);
                          }
                          imagedestroy($simage1);

                     switch ($image_size[2]){
                       case 1:
                       $source =imagejpeg($thumb,$destination);
                       break;
                       case 2:
                       $source =imagejpeg($thumb,$destination);
                       break;
                       case 3:
                       $source =imagepng($thumb,$destination);
                       break;
                       case 6:
                       $source =imagewbmp($thumb,$destination);
                       break;
                     default:
                     }
                     imagedestroy($thumb);
               ##################
               }
               if( $image_size[0] > $Bingz_images_width ){
                 	   $destinationaa = $destination_folder.$fjname.$time."_data.".$ftype;
                     @copy($destination,$destinationaa);
                     $newwidth = $Bingz_images_width;
                     $newheight = $image_size[1]/($image_size[0]/$Bingz_images_width);
                     $thumb = imagecreatetruecolor($newwidth, $newheight);
                     switch ($image_size[2]){
                       case 1:
                       $source =imagecreatefromgif($destination);
                       break;
                       case 2:
                       $source =imagecreatefromjpeg($destination);
                       break;
                       case 3:
                       $source =imagecreatefrompng($destination);
                       break;
                       case 6:
                       $source =imagecreatefromwbmp($destination);
                       break;
                     default:
                     }
                     imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $image_size[0], $image_size[1]);
                     switch ($image_size[2]){
                       case 1:
                       $source =imagejpeg($thumb,$destination);
                       break;
                       case 2:
                       $source =imagejpeg($thumb,$destination);
                       break;
                       case 3:
                       $source =imagepng($thumb,$destination);
                       break;
                       case 6:
                       $source =imagewbmp($thumb,$destination);
                       break;
                     default:
                     }
                     imagedestroy($thumb);
               }
           }
        }
        $wjdx=floor($wjdx);
        $mmm=array('1' => '1','2' => $fname,'3'=> $wjdx,'4'=> $fjcks,'5'=> $file['name'],'6'=> $watermark);
    }
}else{
    $mmm=array('1'=>'0','2'=>'上传模式错误!','3'=>'','4'=>'','5'=>'');
}
	return $mmm;
}
function Bingz_upload_Remote($destination_folder,$rposition,$scfs='3',$fjname=''){
	/*
	1.上传目录
  2.远程地址
	3.上传类型        1图片。2附件。3全部
	4.附文件名称
	*/
	global $db,$time;
  	if($scfs == '1'){
  		       $uptypes=Bingz_config('upload_config_tplx');
  		$max_file_size =Bingz_config('upload_config_tplxdx');
  	}elseif($scfs == '2'){
  		       $uptypes=Bingz_config('upload_config_fjlx');
  		$max_file_size =Bingz_config('upload_config_fjlxdx');
  	}elseif($scfs == '3'){
  		       $uptypes=''.Bingz_config('upload_config_fjlx').','.Bingz_config('upload_config_tplx').','.$scfs;
  		$max_file_size =Bingz_config('upload_config_fjlxdx');
  	}else{
  		$uptypes=$scfs;
  		$max_file_size ='50000';
  	}
    $watermark    =Bingz_config('upload_config_sysz');
    $waterstring  =Bingz_config('upload_config_syname');
    $waterposition=Bingz_config('upload_config_sydz');
    if(!file_exists($destination_folder)){
        @mkdir($destination_folder,0777,true);
    }
    $file=$rposition;
    $ssnm=explode(".",$file);
    $fjcks=$ssnm[count($ssnm)-1];
    $ndn=$ssnm[count(explode("/",$file))-1];
    if($uptypes == "" || !in_array($fjcks,explode(",",$uptypes))){
        $mmm=array('1'=>'0','2'=>'文件类型不符!','3'=>'','4'=>'','5'=>'');
    }else{
        $ext = strrchr($file,".");
        $filename =$destination_folder.$fjname.$time.$ext;
        ob_start();
        readfile($file);
        $img=ob_get_contents();
        ob_end_clean ();
        $fp2 =@fopen($filename,"a");
        fwrite($fp2,$img);
        fclose($fp2);
        $wjdxb=abs(filesize($filename));
        $wjdx=$wjdxb/1024;
        $wjdx=round($wjdx,2);
        $destination = $filename;
    if($wjdxb < '1'){
       $mmm=array('1'=>'0','2'=>'文件不存在!','3'=>'','4'=>'','5'=>'');
    	 unlink ("$filename");
    }else if($max_file_size < $wjdx){
       $mmm=array('1'=>'0','2'=>"文件太大!系统规定上传 $max_file_size kb",'3'=>'','4'=>'','5'=>'');
    	 unlink ("$filename");
    }else{
       $pinfo=pathinfo($filename);
       $fname=$pinfo[basename];
       $wjdx=floor($wjdx);
       $mmm=array('1' => '1','2' => $fname,'3' => $wjdx,'4' => $fjcks,'5'=> $ndn);
    }
  }
	return $mmm;
}
function Bingz_download($url_fj,$name){
	  global $_SERVER;
$fname=$url_fj;
$fp = fopen($fname,'rb'); 
$fsize = filesize($fname); 
if (isset($_SERVER['HTTP_RANGE']) && ($_SERVER['HTTP_RANGE'] != "") && preg_match("/^bytes=([0-9]+)-$/i", $_SERVER['HTTP_RANGE'], $match) && ($match[1] < $fsize)) { 
   $start = $match[1]; 
} else { 
   $start = 0; 
} 
Header("Cache-control: public"); 
Header("Pragma: public"); 
if ($start > 0) {
fseek($fp, $start);
Header("HTTP/1.1 206 Partial Content");
Header("Content-Length: ".($fsize - $start));
Header("Content-Ranges: bytes".$start."-".($fsize - 1)."/".$fsize);
} else {
Header("Content-Length: ".$fsize."");
Header("Accept-Ranges: bytes");
}
Header("Content-Type: application/octet-stream");
Header("Content-Disposition: attachment;filename=".$name."");
fpassthru($fp);
}
############################################/*提交数据post*/
function Bingz_forum_post($fid,$uid,$name,$content,$suo='0',$flid='0',$type_lx='0',$sz_tz='1',$sz_lm='0'){
	  global $time,$db,$time,$ip;
if(!$suo){$suo='0';}
if(!$flid){$flid='0';}
       if($db->insert('forum',array('id' => 'NULL', 'cid' => $fid, 'uid' => $uid,'uip' => $ip, 'uname' => 'NULL','fid' => $flid,'name' => $name,'content' => $content, 'time_a'=> $time, 'time_b'=> $time, 'type_suo'=> $suo, 'type_lx'=> $type_lx, 'sz_tz'=> $sz_tz, 'sz_lm'=> $sz_lm))){
             $id=$db->insert_id();
             $db->update('forum_class',array( 'tzsz' => '+1' ,'tzszj' => '+1' ,'tzst' => '+1' )," `id` ='$fid'");
             $fsmstz=Bingz_config('forum_config_ftz');
             $forum_config_fjb=Bingz_config('forum_config_fjb');
             $forum_config_fjy=Bingz_config('forum_config_fjy');
             if($forum_config_fjb > '0'){
             Bingz_management($uid,'money','+'.$forum_config_fjb.'','发表帖子奖励！','','','','','','','',$fsmstz);
             }
             if($forum_config_fjy > '0'){
             Bingz_management($uid,'jifen','+'.$forum_config_fjy.'','发表帖子奖励！','','','','','','','',$fsmstz);
		         }
		         return $id;
       }
}
function Bingz_forum_upload_post($uid,$rposition,$money='0'){
	  global $time,$db,$time,$ip;
            $mmurl=date("Y/m/d/");
            $bzwjc=Bingz_upload_Remote('data/forum/'.$mmurl,$rposition,'1');
            if($bzwjc[1] == '1'){
          	 if(in_array($bzwjc[4], array('jpg','jpeg','png','gif'))) {$fjlx='1';}else{$fjlx='2';}
             if($db->insert('forum_data',array('id' => 'NULL', 'uid' => $uid, 'money' => $money, 'url' => ''.$mmurl.$bzwjc[2].'','name' => $bzwjc['5'],'fjgs' => $fjlx,'fjlx' => $bzwjc['4'],'size' => $bzwjc['3'], 'time_a'=> $time))){
                $id=$db->insert_id();
                return $id;
             }
            }
}
function Bingz_forum_hui_post($fid,$uid,$content,$hfid='',$hfts=''){
	  global $time,$db,$time,$ip;
	         if(!$hfid){$hfid='0';$hfts='0';}
           $forum=$db->get_one('forum'," `id` ='$fid' ",'');
           $forumclass=$db->get_one('forum_class'," `id` ='$forum[cid]'",'');
          if($db->insert('forum_hui',array('id' => 'NULL' ,'uid' => $uid,'uip' => $ip,'cid' => $forumclass[id],'fid' => $forum[id] ,'fbfs' => '0','gl' => '0','content' => $content,'type_hfid' => $hfid,'type_hfts' => $hfts,'type_xs_hy' => '0','time_a' => $time))){
             $db->update('forum',array( 'hfs' => '+1' , 'time_a' => $time),"`id` ='$fid'");
             $db->update('forum_class',array('tzsz' => '+1' ,'tzszj' => '+1' ,'tzsh' => '+1'),"`id` ='$forumclass[id]'");
             $hsmstz=Bingz_config('forum_config_htz');
             $forum_config_hjb=Bingz_config('forum_config_hjb');
             $forum_config_hjy=Bingz_config('forum_config_hjy');
             if($forum_config_hjb > '0'){
             Bingz_management($user_uid,'money','+'.$forum_config_hjb.'','回复帖子奖励！','','','','','','','',$hsmstz);
             }
             if($forum_config_hjy > '0'){
             Bingz_management($user_uid,'jifen','+'.$forum_config_hjy.'','回复帖子奖励！','','','','','','','',$hsmstz);
             }
             return $fid;
          }
}
function Bingz_message_post($fid,$tid,$content){
	  global $time,$db;
       $db->insert('message',array('id' => 'NULL', 'fo_id' => $fid, 'to_id' => $tid, 'content' => $content, 'time_a'=> $time ));
       $version=$db->insert_id();
    return $version;
}
############################################
function Bingz_collection($url,$android_ua='',$content=''){
     $cn=curl_init();
     if(!$android_ua){$android_ua='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36';}
     curl_setopt($cn,CURLOPT_URL,"".$url."");
     curl_setopt($cn,CURLOPT_USERAGENT,$android_ua);
     curl_setopt($cn,CURLOPT_RETURNTRANSFER,1);
     $content=curl_exec($cn);
     curl_close($cn);
    return $content;
}
function Bingz_http($url,$android_ua=''){
      $pass=substr(trim($url),0,7);
      if(in_array($pass, array('http://','HTTP://'))) {
          $name=$url;
      }else{
          $name='http://'.$url;
      }
	 return $name;
}
function Bingz_html($content){//输出过滤
	  	global $_config;
   $ArrFiltrate=explode(',',$_config['config']['contentgl']);
   foreach ($ArrFiltrate as $key){
       if (@eregi($key,$content)){
          $content=str_replace($key,$_config['config']['contentth'],$content);
       }
   }
   return htmlentities($content,ENT_QUOTES,'utf-8');
}
function page_num($list_num,$num_count){
	global $HTTP_POST_VARS,$HTTP_GET_VARS;
	   $page=$_GET['page'];
	   $page_count=@ceil($num_count/$list_num);
     if(empty($page)){ $page=1; }
	   if($page > $page_count){ $page=$page_count; }
	   if($page < 1){ $page=1; }
	   $num_start=($page-1)*$list_num;
	return $num_start;
}
function page_link($list_num,$num_count,$url=''){
	global $HTTP_POST_VARS,$HTTP_GET_VARS,$Bingz_html;
	$page=$_GET['page'];
	$page_count=@ceil($num_count/$list_num);
	if($page > $page_count){ $page=$page_count;}
	if(empty($page)){ $page=1; }

if(!preg_match('/.html/',$_SERVER['REQUEST_URI'])){
   $url_ur=explode("&page",$_SERVER['REQUEST_URI']);
   $p_next=$page+1 ;
   $p_up=$page-1;
   if($p_up < 1){$p_up='1' ;}
   if($p_next > $page_count){$p_next=$page_count ;}
   if($page_count > 1){
          $papa='<div id="dataPager" class="pages">
            <a id="lnkBtnFirst" class="fir" href="'.$url_ur[0].'&page=1">首页</a>
            <a id="lnkBtnPrev" class="up" href="'.$url_ur[0].'&page='.$p_up.'">上一页</a>
            <span>
                <input name="txtShowPages" type="text" value="'.$page.'/'.$page_count.'" id="txtShowPages" disabled="disabled" class="goto" /></span>
            <a id="lnkBtnNext" class="next" href="'.$url_ur[0].'&page='.$p_next.'">下一页</a>
            <a id="lnkBtnLast" class="end" href="'.$url_ur[0].'&page='.$page_count.'">尾页</a></div>
                <div class="clr"></div>';
   }
}else{
   $url_ur=explode("_",$_SERVER['REQUEST_URI']);
   if(!$url_ur[1]){
   	   $url_ur=explode(".html",$_SERVER['REQUEST_URI']);
   }
   $p_next=$page+1 ;
   $p_up=$page-1;
   if($p_up < 1){$p_up='1' ;}
   if($p_next > $page_count){$p_next=$page_count ;}
   if($page_count > 1){
          $papa='<div id="dataPager" class="pages">
            <a id="lnkBtnFirst" class="fir" href="'.$url_ur[0].'_1.html">首页</a>
            <a id="lnkBtnPrev" class="up" href="'.$url_ur[0].'_'.$p_up.'.html">上一页</a>
            <span>
                <input name="txtShowPages" type="text" value="'.$page.'/'.$page_count.'" id="txtShowPages" disabled="disabled" class="goto" /></span>
            <a id="lnkBtnNext" class="next" href="'.$url_ur[0].'_'.$p_next.'.html">下一页</a>
            <a id="lnkBtnLast" class="end" href="'.$url_ur[0].'_'.$page_count.'.html">尾页</a></div>
                <div class="clr"></div>';
   }
}
	 return $papa;
}
############################################/*金币积分管理*/
function Bingz_renminbi_mm($type){//支付密码
	  	 $renminbi=md5(md5(substr(md5(md5($type)),-20,18)));
	     return $renminbi;
}
function Bingz_renminbi_pass($type){//金额密码
	  	global $Bingz_renminbi_pass;
	  	 $renminbi=md5(md5(substr(md5(md5($type)),-10,18)));
	     return $renminbi;
}
function Bingz_renminbi_pass_yz($uid,$yzm,$pass){//用户支付密码判断
	  	global $db;
	  	 $passhy=md5($yzm);
	  	 $passxz=Bingz_renminbi_mm($pass);
       if($db->get_one('user',"`renminbi_pass` = '$passxz' and `uid` = '$uid'",'') && $db->get_one('user_pass',"`pass` = '$passhy' and `uid` = '$uid'",'') ){
	        return $uid;
	     }
}
function Bingz_renminbi($uid,$type='0'){
	  	global $db,$ubb;
	  	 $usera=$db->get_one('user'," `uid` = '$uid'",'`renminbi`,`renminbi_zt`');
        if($usera['renminbi_zt'] == '0' ){
        	  if($usera['renminbi'] > '0'){
        	     $userrenminbi=$db->get_one('user_renminbi'," `uid` = '$uid' ORDER BY `id` DESC LIMIT 0 ,1",'`pass`');
               if(Bingz_renminbi_pass($usera['renminbi']) != $userrenminbi['pass']){
                   $db->update('user',array('renminbi_zt' => 1),"`uid` = '$usera[uid]'");
                   $renminbi='<STRIKE>'.$usera['renminbi'].'</STRIKE>(<font color="#ff0000">冻结</font>)';
               }else{
                   $renminbi=$usera['renminbi'];
               }
        	  }else{
                   $renminbi=$usera['renminbi'];
        	  }
        }else{
            $renminbi='<STRIKE>'.$usera['renminbi'].'</STRIKE>(<font color="#ff0000">冻结</font>)';
        }
       if($type > '0'){
       	  $renminbi=$usera['renminbi'];
       }
	     return $renminbi;
}
function Bingz_management_name($type){
      	  if($type == 'jifen'){
      	           $manag=Bingz_config('Site_config_jf_name');
	        }elseif($type == 'money'){
      	           $manag=Bingz_config('Site_config_jb_name');
      	  }elseif($type == 'yeobi'){
      	           $manag=Bingz_config('Site_config_yb_name');
      	  }elseif($type == 'renminbi'){
      	           $manag=Bingz_config('Site_config_rmb_name');
      	  }
     return $manag;
}
function Bingz_management_pd($uid,$type,$management){
	  global $bzxt,$db;
	  $usera=$db->get_one('user'," `uid` = '$uid'",' ');
          if($type == 'money'){
      	      if($management < $usera[money]){
      	           $manag=$management;
      	      }
      	  }elseif($type == 'jifen'){
      	      if($management < $usera[jifen]){
      	           $manag=$management;
      	      }
      	  }elseif($type == 'yeobi'){
      	      if($management < $usera[yeobi]){
      	           $manag=$management;
      	      }
      	  }elseif($type == 'renminbi'){
      	      if($management < $usera[renminbi]){
      	           $manag=$management;
      	      }
      	  }
     return $manag;
}
function Bingz_management($uid,$type,$name,$content='未知操作',$yzm='',$pass='',$lx='2',$zdmmm='',$ztts='1',$ztname='操作成功',$bzname='',$znsmstz='0',$smspost='0'){
	  //$smspost短信通知
	  //$lx=1充值2消费3提现
	  global $bzxt,$db,$Bingz_renminbi_pass,$url_b,$ip,$time;
	  $czzhxx=$db->get_one('user_renminbi',"`name` = '$zdmm' ",' ');
	  if(!$uid){$uid=$czzhxx[uid];}
    $nammp=substr(trim($name),0,1);
    $passxz=Bingz_renminbi_mm($pass);
    $passhy=md5($yzm);
    if(!$zdmmm){$zdmm=date("YmdHis");}else{$zdmm=$zdmmm;}
    $xtnamepd=explode($nammp,$name);
    $management=$xtnamepd[1];
    $nammpmm=substr(trim($management),0,1);
    if(in_array($nammp, array('-','+')) && is_numeric($management) && preg_match("/^\d+$/i",$nammpmm)) {
      	  if($management < '0.01'){
             $manag='-2';//金额有错误
             Bingz_Error_Reporting('金额有错误-2  会员('.$uid.') 类型('.$type.') 金额('.$name.') 备注('.$content.') ','支付系统','user_renminbi');
      	  }elseif($type == 'money'){
      	  		     $db->update('user'," `money` = `money` $nammp $management "," `uid` ='$uid'");
	    		       if($znsmstz == '1'){
	    		       	  $dxtx='你好！系统操作([b]'.Bingz_config('Site_config_jb_name').'[/b]:[color=#ff0000]'.$nammp.$management.'[/color])。///原因([color=#ff0000]'.$content.'[/color])';
      	            Bingz_message_post('0',$uid,$dxtx);
      	         }
      	           $manag=$management;
      	  }elseif($type == 'jifen'){
      	  		     $db->update('user'," `jifen` = `jifen` $nammp $management "," `uid` ='$uid'");
	    		       if($znsmstz == '1'){
	    		          $dxtx='你好！系统操作([b]'.Bingz_config('Site_config_jf_name').'[/b]:[color=#ff0000]'.$nammp.$management.'[/color])。///原因([color=#ff0000]'.$content.'[/color])';
      	            Bingz_message_post('0',$uid,$dxtx);
      	         }
      	           $manag=$management;
      	  }elseif($type == 'yeobi'){
      	  		     $db->update('user'," `yeobi` = `yeobi` $nammp $management "," `uid` ='$uid'");
	    		       if($znsmstz == '1'){
	    		          $dxtx='你好！系统操作([b]'.Bingz_config('Site_config_yb_name').'[/b]:[color=#ff0000]'.$nammp.$management.'[/color])。///原因([color=#ff0000]'.$content.'[/color])';
      	            Bingz_message_post('0',$uid,$dxtx);
      	         }
      	           $manag=$management;
      	  }elseif($type == 'renminbi'){
      	  	       Bingz_renminbi($uid);
      	      	   if($db->get_one('user',"`renminbi_zt` = '0' and `uid` = '$uid'",' ')){
      	      	   	     $userrmb=$db->get_one('user',"`uid` = '$uid'",'');
      	      	   	     if($nammp == '+'){
      	      	   	        $xzrmbb=sprintf("%.2f",($userrmb[renminbi]+$management) );
      	      	   	     }else{
      	      	   	        $xzrmbb=sprintf("%.2f",($userrmb[renminbi]-$management) );
      	      	   	     }
      	      	   	     if($Bingz_renminbi_pass == $pass && !$yzm){
      	  		                 if($lx == '1' && $zdmmm){
      	  		                 	   if($czzh=$db->get_one('user_renminbi',"`renminbi_ztsz` = '2' and `name` = '$zdmm' ",' ')){
      	  		                 	      $nammp=substr(trim($czzh[renminbi_cz]),0,1);
      	  		                 	      $xtnamepd=explode($nammp,$czzh[renminbi_cz]);
      	  		                 	      $management=intval($xtnamepd[1]);
      	  		                 	      if($nammp == '+'){
      	      	   	                     $xzrmbb=sprintf("%.2f",($userrmb[renminbi]+$management));
      	      	   	                  }else{
      	      	   	                     $xzrmbb=sprintf("%.2f",($userrmb[renminbi]-$management));
      	      	   	                  }
      	  		                        $db->update('user'," `renminbi` = `renminbi` $nammp $management  "," `uid` ='$uid'");
      	  		                        $xzzhje=Bingz_renminbi_pass($xzrmbb);      	  		                        
      	  		                        $db->update('user_renminbi'," `pass` = '$xzzhje' ,`renminbi` = '$xzrmbb' ,`renminbi_ztsz` = '1' ,`renminbi_ztname` = '充值成功' "," `id` = '$czzh[id]' ");
	    		                            $dxtx='你好！系统操作([b]'.$bzxt['w_rmb_name'].'[/b]:[color=#ff0000]'.$nammp.$management.'[/color])。///原因([color=#ff0000]充值成功[/color])///账单号('.$zdmm.')';
      	                              Bingz_message_post('0',$uid,$dxtx);
      	  		                        Bingz_config('renminbi_config_renminbi',$czzh[renminbi_cz],'post');
      	  		                 	   }elseif(!$db->get_one('user_renminbi',"`name` = '$zdmm' and `uid` = '$uid'",' ')){
      	  		                        $xzzhje=Bingz_renminbi_pass($userrmb[renminbi]);
      	  		                        $db->insert('user_renminbi',array('id' => 'NULL' ,'uid' => $uid,'uip' => $ip,'url' => $url_b,'pass' => $xzzhje,'name' => $zdmm,'type' => $lx,'renminbi' => $userrmb[renminbi],'renminbi_yl' => $userrmb[renminbi],'renminbi_cz' => ''.$nammp.$management.'','renminbi_ztsz' => '2','renminbi_ztname ' => '等待付款','content' => $content,'time_a' => $time));
	    		                            $dxtx='你好！系统操作([b]'.Bingz_config('Site_config_rmb_name').'[/b]:[color=#ff0000]'.$nammp.$management.'[/color])。///原因([color=#ff0000]'.$content.'[/color])///状态：等待付款///账单号('.$zdmm.')';
      	                               Bingz_message_post('0',$uid,$dxtx);
                                   }
      	  		                 }else{
      	  		                     $db->update('user'," `renminbi` = `renminbi` $nammp $management "," `uid` ='$uid'");
      	  		                     $xzzhje=Bingz_renminbi_pass($xzrmbb);
      	  		                     $db->insert('user_renminbi',array('id' => 'NULL' ,'uid' => $uid,'uip' => $ip,'url' => $url_b,'pass' => $xzzhje,'name' => $zdmm,'type' => $lx,'renminbi' => $xzrmbb,'renminbi_yl' => $userrmb[renminbi],'renminbi_cz' => ''.$nammp.$management.'','renminbi_ztsz' => $ztts,'renminbi_ztname ' => $ztname,'content' => $content,'votes' => $bzname,'time_a' => $time));
	    		                         $dxtx='你好！系统操作([b]'.Bingz_config('Site_config_rmb_name').'[/b]:[color=#ff0000]'.$nammp.$management.'[/color])。///原因([color=#ff0000]'.$content.'[/color])///账单号('.$zdmm.')';
      	                           Bingz_message_post('0',$uid,$dxtx);
      	                           Bingz_config('renminbi_config_renminbi',$name,'post');
      	                       }
      	      	   	     	     $manag=$management;
      	      	   	     	     Bingz_Error_Reporting('系统支付操作成功  会员('.$uid.') 类型('.$type.') 金额('.$name.') 备注('.$content.') ','支付系统','user_renminbi');
      	      	   	     	     	   if(Bingz_config('email_set_payment') == '1'){
	   	                                    $email_set_reg_title=Bingz_config('email_set_payment_title');
	   	                                    $email_set_reg_title=str_replace('{number}',$zdmm,$email_set_reg_title);
	   	                                    $email_set_reg_body=Bingz_config('email_set_payment_body');
	   	                                    $email_set_reg_body=str_replace('{title}',$content,$email_set_reg_body);
	   	                                    $email_set_reg_body=str_replace('{number}',$zdmm,$email_set_reg_body);
	   	                                    Bingz_email_smtp_post($userrmb[email],$email_set_reg_title,$email_set_reg_body);
	   	                             }
      	      	   	     	     	   if(Bingz_config('sms_set_payment') == '1' && $smspost == '1'){
	   	                                    $email_set_reg_body=Bingz_config('sms_set_payment_body');
	   	                                    $email_set_reg_body=str_replace('{title}',$content,$email_set_reg_body);
	   	                                    $email_set_reg_body=str_replace('{number}',$zdmm,$email_set_reg_body);
	   	                                    Bingz_sms_post($userrmb[mobile],$email_set_reg_body);
	   	                             }
      	      	   	     
      	      	   	     }elseif($db->get_one('user',"`renminbi_pass` = '$passxz' and `uid` = '$uid'",'') && $db->get_one('user_pass',"`pass` = '$passhy' and `uid` = '$uid'",'') ){
      	  		                 $db->update('user'," `renminbi` = `renminbi` $nammp $management "," `uid` ='$uid'");
      	  		                 $xzzhje=Bingz_renminbi_pass($xzrmbb);
      	  		                 $db->insert('user_renminbi',array('id' => 'NULL' ,'uid' => $uid,'uip' => $ip,'url' => $url_b,'pass' => $xzzhje,'name' => $zdmm,'type' => $lx,'renminbi' => $xzrmbb,'renminbi_yl' => $userrmb[renminbi],'renminbi_cz' => ''.$nammp.$management.'','renminbi_ztsz' => $ztts,'renminbi_ztname ' => $ztname,'content' => $content,'votes' => $bzname,'time_a' => $time));
	    		                     $dxtx='你好！系统操作([b]'.Bingz_config('Site_config_rmb_name').'[/b]:[color=#ff0000]'.$nammp.$management.'[/color])。///原因([color=#ff0000]'.$content.'[/color])///账单号('.$zdmm.')';
      	                       Bingz_message_post('0',$uid,$dxtx);
      	                       
      	                       Bingz_config('renminbi_config_renminbi',$name,'post');
      	      	   	     	     $manag=$management;
      	      	   	     	     Bingz_Error_Reporting('会员支付成功  会员('.$uid.') 类型('.$type.') 金额('.$name.') 备注('.$content.') ','支付系统','user_renminbi');
      	      	   	     	     	   if(Bingz_config('email_set_payment') == '1'){
	   	                                    $email_set_reg_title=Bingz_config('email_set_payment_title');
	   	                                    $email_set_reg_title=str_replace('{number}',$zdmm,$email_set_reg_title);
	   	                                    $email_set_reg_body=Bingz_config('email_set_payment_body');
	   	                                    $email_set_reg_body=str_replace('{title}',$content,$email_set_reg_body);
	   	                                    $email_set_reg_body=str_replace('{number}',$zdmm,$email_set_reg_body);
	   	                                    Bingz_email_smtp_post($userrmb[email],$email_set_reg_title,$email_set_reg_body);
	   	                             }
      	      	   	     	     	   if(Bingz_config('sms_set_payment') == '1' && $smspost == '1'){
	   	                                    $email_set_reg_body=Bingz_config('sms_set_payment_body');
	   	                                    $email_set_reg_body=str_replace('{title}',$content,$email_set_reg_body);
	   	                                    $email_set_reg_body=str_replace('{number}',$zdmm,$email_set_reg_body);
	   	                                    Bingz_sms_post($userrmb[mobile],$email_set_reg_body);
	   	                             }
      	      	   	     
      	      	   	     }else{
      	      	   	     	 $manag='-5';//验证有错误
      	      	   	     	 Bingz_Error_Reporting('验证有错误-5  会员('.$uid.') 类型('.$type.') 金额('.$name.') 备注('.$content.') ','支付系统','user_renminbi');
      	      	   	     }
                   }else{
                       $manag='-4';//账号冻结
                       Bingz_Error_Reporting('账号冻结-4  会员('.$uid.') 类型('.$type.') 金额('.$name.') 备注('.$content.') ','支付系统','user_renminbi');
      	      	   }
      	  }else{
      	  	 $manag='-3';//支付类型错误
      	  	 Bingz_Error_Reporting('支付类型错误-3  会员('.$uid.') 类型('.$type.') 金额('.$name.') 备注('.$content.') ','支付系统','user_renminbi');
      	  }
    }else{
          $manag='-1';//提交错误
          Bingz_Error_Reporting('提交错误-1  会员('.$uid.') 类型('.$type.') 金额('.$name.') 备注('.$content.') ','支付系统','user_renminbi');
    }
    return $manag;
}

function authcode($string,$operation='DECODE',$key='',$expiry=0) {
	$ckey_length = 4;
	$key = md5($key ? $key : UC_KEY);
	$keya = md5(substr($key, 0, 16));
	$keyb = md5(substr($key, 16, 16));
	$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
	$cryptkey = $keya.md5($keya.$keyc);
	$key_length = strlen($cryptkey);
	$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
	$string_length = strlen($string);
	$result = '';
	$box = range(0, 255);
	$rndkey = array();
	for($i = 0; $i <= 255; $i++) {
		$rndkey[$i] = ord($cryptkey[$i % $key_length]);
	}

	for($j = $i = 0; $i < 256; $i++) {
		$j = ($j + $box[$i] + $rndkey[$i]) % 256;
		$tmp = $box[$i];
		$box[$i] = $box[$j];
		$box[$j] = $tmp;
	}

	for($a = $j = $i = 0; $i < $string_length; $i++) {
		$a = ($a + 1) % 256;
		$j = ($j + $box[$a]) % 256;
		$tmp = $box[$a];
		$box[$a] = $box[$j];
		$box[$j] = $tmp;
		$result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
	}

	if($operation == 'DECODE') {
		if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
			$content=substr($result, 26);
			$content=str_replace('\"','"',$content);
      $content=str_replace("\'","'",$content);
			return $content;
		} else {
			return '';
		}
	} else {
		return $keyc.str_replace('=', '', base64_encode($result));
	}
}
function Bingz_statistics(){//访问统计
	global $user_uid,$url_b,$db,$ip,$time,$wappced;
	 $url_bb=authcode($url_b,$operation='ok');
   $timextc =strtotime(date("Y-m-d 00:00:00"));
   if(!$db->get_one('website_statistics'," `time_a` = '$timextc' ",'id')){
	     $db->insert('website_statistics',array('id' => 'NULL' ,'time_a' => $timextc ));
   }
   $fwsm=$db->get_one('website_statistics'," ORDER BY `id` DESC LIMIT 0 , 1 ",'id');
   if(!$user_uid ){$user_uid='0';} 
   if($user_uid > '0' && !$db->get_one('website_userdt'," `uid` ='$user_uid'",'id')){
 	    $db->update('website_statistics',array('user' => '+1' ),"`id` ='$fwsm[id]'");	
   }	
	  if($iphy=$db->get_one('website_userdt'," `uip` ='$ip' ",'id')){
		    $db->update('website_userdt',array('uid' => $user_uid,'url' => $url_bb, 'time_a' => $time ,'pv' => '+1' ),"`id` ='$iphy[id]' ");
        if($wappced == 'wap'){
           $db->update('website_statistics',array('wap_pv' => '+1' ),"`id` ='$fwsm[id]'");
        }else if($wappced == 'wpc'){
           $db->update('website_statistics',array('wpc_pv' => '+1' ),"`id` ='$fwsm[id]'");
        }else if($wappced == 'web'){
           $db->update('website_statistics',array('web_pv' => '+1' ),"`id` ='$fwsm[id]'");
        }
    }else{
        $db->insert('website_userdt',array('id' => 'NULL' ,'uid' => $user_uid,'uip' => $ip,'time_a' => $time,'time_b' => $time,'pv' => 1,'url' => $url_bb));
        if($wappced == 'wap'){
           $db->update('website_statistics',array('wap_ip' => '+1' ),"`id` ='$fwsm[id]'");
        }else if($wappced == 'wpc'){
           $db->update('website_statistics',array('wpc_ip' => '+1' ),"`id` ='$fwsm[id]'");
        }else if($wappced == 'web'){
           $db->update('website_statistics',array('web_ip' => '+1' ),"`id` ='$fwsm[id]'");
        }
    }
return $wappced;
}
function Bingz_cache_html($melu='cache',$content='index',$suan='0'){
	  	global $Bingz_cache,$templatesname,$time;
	  	if($Bingz_cache > '0' ){
	  		 Bingz_create_folder('cache/'.$melu.'');
	  	   $wzfbbhtml='cache/'.$melu.'/'.$content.'_'.$templatesname.'.html';
         if(file_exists($wzfbbhtml)){
	               if(($time - filemtime($wzfbbhtml)) < $Bingz_cache or $suan == '1'){
                     $fp = fopen($wzfbbhtml, 'r');
                     $filesize=filesize($wzfbbhtml);
                     $sql = fread($fp, $filesize);
                     fclose( $fp );
                     return $sql;
                 }else{
                     @unlink($wzfbbhtml);
                 }
         }
      }
}
function Bingz_cache_html_delete($melu='cache',$content='index'){
	  	global $Bingz_cache,$templatesname,$time;
	  		 Bingz_create_folder('cache/'.$melu.'');
	  	   $wzfbbhtml='cache/'.$melu.'/'.$content.'_'.$templatesname.'.html';
         @unlink($wzfbbhtml);
}
function Bingz_huancunhtml($melu,$time='1'){
	  	global $time,$user_uid;
	  	if(!$user_uid && Bingz_config('system_config_huancunhtml') == '1'){
	        if(file_exists(MBLOG_ROOT.''.$melu.'.html')){
	           	if((($time - filemtime(MBLOG_ROOT.''.$melu.'.html'))/3600) > $time ){
	           	  $Bingzip=ob_get_contents();
	           	  $fp   =fopen(MBLOG_ROOT.''.$melu.'.html','w');
	           	  fwrite($fp,$Bingzip);
	           	  fclose($fp);
	           	}
	        }else{
	           	  $Bingzip=ob_get_contents();
	           	  $fp   =fopen(MBLOG_ROOT.''.$melu.'.html','w');
	           	  fwrite($fp,$Bingzip);
	           	  fclose($fp);
	        }
      }
}
function Bingz_cache_html_post($melu='cache',$content='index',$name,$lx=''){
	  	global $Bingz_cache,$templatesname,$time;
	  	if($Bingz_cache > '0'){
	  		 Bingz_create_folder('cache/'.$melu.'');
	  	   $wzfbbhtml='cache/'.$melu.'/'.$content.'_'.$templatesname.'.html';
         if($lx == '1'){
	          $fp = fopen($wzfbbhtml,'a+');
	          fwrite($fp,$name);
	          fclose($fp);
	       }else{
	          $fp = fopen($wzfbbhtml,'w');
	          fwrite($fp,$name);
	          fclose($fp);
	       }
         return $wzfbbhtml;
      }
}
if(!preg_match('/admin.php/',$_SERVER['REQUEST_URI'])){
foreach ($_GET as $get_key=> $get_var) {
  $get[strtolower($get_key)] = daddsla_add($get_var,'1'); 
}
$_GET=$get;
foreach ($_POST as $post_key=>$post_var) {
    $post[strtolower($post_key)] = daddsla_add($post_var); 
}
$_POST=$post;
foreach ($_COOKIE as $post_key=>$post_var) {
    $cookle[strtolower($post_key)] = daddsla_add($post_var); 
}
$_COOKIE=$cookle;
}
?>
